home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / CURSOR.SWG / 0024_cursor stuff.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  4KB  |  128 lines

  1. {To make all cursor routines complete, here are the ones I use: }
  2.  
  3. procedure setcursorshape(shape : word); assembler; asm
  4.   mov ah,1; mov cx,shape; int 10h; end;
  5.  
  6. procedure linecursor;
  7. begin
  8.   case Rows of
  9.     25 : case VidCard of
  10.            cga,ega : setcursorshape(256*6+7);
  11.            mda : setcursorshape(256*$b+$c);
  12.            vga : setcursorshape(256*$d+$e);
  13.          else setcursorshape(256*6+7);
  14.          end;
  15.     40 : setcursorshape(256*8+9);
  16.   else setcursorshape(256*6+7);
  17.   end;
  18. end;
  19.  
  20. procedure halfcursor;
  21. begin
  22.   case Rows of
  23.     25 : case VidCard of
  24.            cga,ega : setcursorshape(256*3+7);
  25.            mda : setcursorshape(256*6+$c);
  26.            vga : setcursorshape(256*7+$e);
  27.          else setcursorshape(256*3+7);
  28.          end;
  29.     40 : setcursorshape(256*4+9);
  30.   else setcursorshape(256*3+7);
  31.   end;
  32. end;
  33.  
  34. procedure blockcursor; begin
  35.   setcursorshape($10); end;
  36.  
  37. procedure cursoron; assembler; asm
  38.   mov ah,3; mov bh,0; int 10h; and ch,not 20h; mov ah,1; int 10h; end;
  39.  
  40. procedure cursoroff; assembler; asm
  41.   mov ah,3; mov bh,0; int 10h; or ch,20h; mov ah,1; int 10h; end;
  42.  
  43. function getcursorshape : word; assembler; asm
  44.   mov ah,3; mov bh,0; int 10h; mov ax,cx; end;
  45.  
  46. >--- cut here 
  47.  
  48. The carddetectionroutines are as follows:
  49.  
  50. >--- cut here 
  51.  
  52. const
  53.   mda = 0;                                                     { MDA and HGC }
  54.   cga = 1;
  55.   ega = 2;
  56.   ega_mono = 3;                                        { EGA and MDA-Monitor }
  57.   vga = 4;
  58.   vga_mono = 5;                                           { VGA and VGA-Mono }
  59.   mcga = 6;
  60.   mcga_mono = 7;                                        { MCGA and MCGA-Mono }
  61.  
  62. var
  63.   VidCard : byte;                                { Code for active videocard }
  64.  
  65. procedure VideoInit;
  66.  
  67. const
  68.   VidMode : array[0..11] of byte = (mda,cga,0,ega,ega_mono,0,vga_mono,
  69.                                     vga,0,mcga,mcga_mono,mcga);
  70.   EgaMode : array[0..2] of byte = (ega,ega,ega_mono);
  71.  
  72. var
  73.   Regs : registers;                           { Processorregisters for int's }
  74.  
  75. begin
  76.   VidCard := $ff;                                { No videocard detected yet }
  77.  
  78.   { --- Check card-type ---------------------------------------------------- }
  79.  
  80.   Regs.ax := $1a00;                                 { Call BIOS function 1Ah }
  81.   intr($10,Regs);
  82.   if Regs.al = $1a then begin                           { VGA of MCGA? - Yes }
  83.     VidCard := VidMode[Regs.bl-1];                      { Get cod from table }
  84.     Color := not ((VidCard = mda) or (VidCard = ega_mono));
  85.   end
  86.   else begin                               { No VGA or MCGA, search EGA-card }
  87.     Regs.ah := $12;                           { Function 12h subfunction 10h }
  88.     Regs.bl := $10;
  89.     intr($10,Regs);                                        { Call Video-BIOS }
  90.     if Regs.bl <> $10 then begin                                { EGA? - Yes }
  91.       VidCard := EgaMode[(Regs.cl shr 1) div 3];                  { Get Code }
  92.       Color := VidCard <> ega_mono;
  93.     end;
  94.   end;
  95.  
  96.   { --- Define pointer to video-RAM ---------------------------------------- }
  97.  
  98.   Regs.ah := 15;                                  { Define actual video-mode }
  99.   intr($10,Regs);                                { Call BIOS video-interrupt }
  100.   if Regs.al = 7 then v_vidseg := $b000                   { Monochrome mode? }
  101.   else v_vidseg := $b800;                                    { No, Colormode }
  102.  
  103.   if VidCard = $ff then begin                   { No EGA, VGA or MCGA? - Yes }
  104.     if Regs.al = 7 then VidCard := mda else VidCard := cga;
  105.     Color := not ((Regs.al = 0) or (Regs.al = 2) or (Regs.al = 7));
  106.     SnowProtect := true;
  107.   end;
  108.  
  109.   Regs.ah := 5;                                   { Chose actual screen page }
  110.   Regs.al := 0;                                                  { Page zero }
  111.   intr($10,Regs);                                { Call BIOS video-interrupt }
  112. end;
  113.  
  114. >--- cut here 
  115.  
  116. This might not compile straight off, but I guess you can imagine what's
  117. possibly missing. ;-) (like 'uses dos')
  118.  
  119. If everything works, you can easily define your cursor with statements as:
  120.  
  121. linecursor,
  122. blockcursor,
  123. cursoroff,
  124. cursoron,
  125. etc...
  126.  
  127. Should work on every possible videocard.
  128.